package cn.com.javafx; 

import javafx.application.Application;  
import javafx.scene.Scene;  
import javafx.scene.control.Button;  
import javafx.scene.layout.StackPane;  
import javafx.stage.Stage;  
   
@SuppressWarnings("restriction")
public class App extends Application{  
   public static void main(String[] args) {  
       launch(args);  
    }  
    
   @Override  
   public void start(Stage primaryStage) {  
       primaryStage.setTitle("Hello World!"); 
       Button btn = new Button();  
       btn.setText("Say 'Hello World'");  
       btn.setOnAction((event)->System.out.println("HelloWorld!"));  
//       btn.setOnAction(new EventHandler<ActionEvent>() {  
//           public void handle(ActionEvent event) {  
//                System.out.println("HelloWorld!");  
//           }  
//       });  
         
       StackPane root = new StackPane();  
       root.getChildren().add(btn);  
       primaryStage.setScene(new Scene(root, 300, 250));  
       primaryStage.show();  
    }  
} 